package Negocio;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Vector;

import Persistencia.AdmPersistenciaItemMineral;
import Persistencia.AdmPersistenciaMineral;


public class ItemMineral {
	private long nroItem;
	private Mineral mineral;
	private double porcentaje;
	private Long nroLote;
	private static ItemMineral instancia;
	
	public ItemMineral (long ni, long m, double por){
		nroItem = ni;
		findMineral(m);
		porcentaje = por;
	}

	public ItemMineral() {
		
	}

	public long getNroItem() 
	{
		return nroItem;
	}

	public void setNroItem(long nroItem) 
	{
		this.nroItem = nroItem;
	}

	
	public Mineral getMineral() 
	{
		return mineral;
	}
    
	public void setMineral (Mineral m)
	{
		this.mineral = m;
	}
	
	public void findMineral(long mineral) {
		this.mineral = (Mineral)AdmPersistenciaMineral.getInstancia().select(new Mineral(mineral,"")).get(0); 
	}

	public double getPorcentaje() {
		return porcentaje;
	}

	public void setPorcentaje(double porcentaje) {
		this.porcentaje = porcentaje;
	}

	
	
	public Long getNroLote() {
		return nroLote;
	}

	public void setNroLote(Long nroLote) {
		this.nroLote = nroLote;
	}

	public static ItemMineral getInstancia() {
		if(instancia == null)
			return new ItemMineral();
		return instancia;
	}

	public Collection<ItemMineral> buscarItems_lote(long nro) {
		System.out.println("Entro a ItemMineral/buscar items para x lote");
		this.setNroItem(nro);
		Collection<ItemMineral> rta = new ArrayList <ItemMineral>();
		Vector <Object> o = new Vector<Object>();
		o = AdmPersistenciaItemMineral.getInstancia().buscarReferencia(nro);
		for(int i=0; i<o.size(); i++){
			rta.add((ItemMineral)o.get(i));
		}
		return rta;
	}
	
	
}
